const jwt = require('jsonwebtoken')
const singKey = 'xuzy_2022_saiBo_xxx'    // 这里可以自己设置
 
exports.setToken = (username) => {
	return new Promise((resolve, reject) => {
		const token = jwt.sign(
			{
				username,
			},
			singKey,
			{
				expiresIn: '1 days',
				algorithm: 'HS256',
			}
		)
		resolve(token)
	})
}
 
exports.verToken = (token) => {
	return new Promise((resolve, reject) => {
		let info = jwt.verify(token.split(' ')[1], singKey)
		resolve(info)
	})
}
 
exports.singKey = singKey